package com.kb5173.search.words.service.impl;

import com.kb5173.search.common.define.enums.ResponseCodes;
import com.kb5173.search.common.exception.WordsException;
import com.kb5173.search.words.service.IWordsService;
import com.kb5173.search.words.dao.nosql.IWordsRedisDAO;
import com.kb5173.framework.common.AbstractBusinessObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author Chengfei.Sun
 */
@Component
public class WordsServiceImpl extends AbstractBusinessObject implements IWordsService {
    @Autowired
    IWordsRedisDAO wordsRedisDAO;

    @Override
    public void addWords(List<String> words) {
        if (words == null || words.size() == 0) {
            throw new WordsException(ResponseCodes.EmptyWords.getCode());
        }
        wordsRedisDAO.addWords(words);
    }

    @Override
    public List<String> getWords() {
        return wordsRedisDAO.getWords();
    }
}
